package com.apci.ipreda.dao;

import java.util.List;

import javax.management.Query;

import com.apci.ipreda.domain.Declaracion;


public class DeclaracionDAOImpl extends BaseDAOHibernate implements DeclaracionDAO{
	
	public Declaracion getDeclaracionById(Long declaracionId){
		return findById(Declaracion.class, declaracionId);
	}
	
	public List<Declaracion> getDeclaracionListByEntidad(Long entidadId) {
		Object[] params = new Object[1];
		params[0] = entidadId; 
		
		return find(Declaracion.class, "from Declaracion where entidadId = ?", params); 
	}

	
	public void saveDeclaracion(Declaracion declaracion) {
		save(declaracion);
	}
	public void update(Declaracion declaracion) {
		update(declaracion);
	}

	
	public Declaracion getDeclaracionByEntidadYPeriodo(Long entidadId,int periodo) {
		Object[] params = new Object[2];
		params[0] = entidadId; 
		params[1] = periodo; 
		return findFirst(Declaracion.class, "from Declaracion where entidadId = ? and periodo = ?", params); 
	}

	public void eliminarDeclaracion(Long declaracionId) {
		Object[] params = new Object[1];
		params[0] = declaracionId;
		Declaracion declaracion = findFirst(Declaracion.class, "from Declaracion where id = ?", params);
		declaracion.setId(declaracionId);
		delete(declaracion);
	}
	
}
